<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:body>
        <p:dialog header="Edit Receipt" widgetVar="carDialog2" resizable="true" id="carDlg2"  
                  showEffect="fade" hideEffect="explode" modal="true" >  
            <h:form id="frmDialog">
                <p:messages id="msgs"/> 

                <h:panelGrid id="display2" cellpadding="4" columns="9" style="margin:0 auto;">

                    <h:outputLabel for="number" value="Number: #{receiptBackBean.selectedReceipt.number} " />

                    <h:outputLabel for="receivedBy" value="Received By: *" />
                    <p:inputText id="receivedBy" value="#{receiptBackBean.selectedReceipt.receivedBy.name}" required="true" label="Received By:" size="30">
                        <f:validateLength minimum="4" />  
                    </p:inputText>
                    <p:message for="receivedBy" id="msgreceivedBy" display="icon"/>

                    <h:outputLabel for="deliveredBy" value="Delivered By: " />
                    <p:inputText id="deliveredBy" value="#{receiptBackBean.selectedReceipt.deliveredBy}" label="Delivered By:" size="30"/>
                    <p:message for="deliveredBy" id="msgdeliveredBy" display="icon"/>

                    <h:outputLabel for="shipper" value="Shipper: *" />
                    <p:inputText id="shipper" value="#{receiptBackBean.selectedReceipt.shipper.firstName}" required="true" label="Shipper:" size="34">
                        <f:validateLength minimum="2" />  
                    </p:inputText>
                    <p:message for="shipper" id="msgShipper" display="icon"/>

                    <h:outputLabel for="consignee" value="Consignee: *" />
                    <p:inputText id="consignee" value="#{receiptBackBean.selectedReceipt.consignee.firstName}" required="true" label="Consignee:" size="34">
                        <f:validateLength minimum="2" />  
                    </p:inputText>
                    <p:message for="consignee" id="msgConsignee" display="icon"/>

                    <h:outputLabel for="description" value="Description: " />
                    <p:inputText id="description" value="#{receiptBackBean.selectedReceipt.description}" label="Description:" size="30"/>
                    <p:message for="description" id="msgDescription" display="icon"/>

                    <h:outputLabel for="pickup" value="Pickup: " />
                    <p:inputText id="pickup" value="#{receiptBackBean.selectedReceipt.pickup}" >  
                        <f:convertNumber integerOnly="true"/>
                    </p:inputText>
                    <p:message for="pickup" id="msgPickup" display="icon"/>

                    <h:outputLabel for="hasInvoice" value="Has Invoice: " />
                    <h:selectBooleanCheckbox id="hasInvoice" value="#{receiptBackBean.selectedReceipt.hasInvoice}"/>
                    <p:message for="hasInvoice" id="msghasInvoice" display="icon"/>

                    <h:outputLabel for="status" value="Status: " />
                    <p:selectOneMenu id="status" value="#{receiptBackBean.selectedReceipt.status}">  
                                <f:selectItems value="#{receiptBackBean.receiptStatusValues}" var="t" 
                                           itemValue="#{t.label}" itemLabel="#{t.label}"/>
                    </p:selectOneMenu>
                    <p:message for="status" id="msgType" display="icon"/>

                </h:panelGrid>

                <p:separator/>
                <p:dataTable id="detailTableId" var="receiptDetail" value="#{receiptBackBean.selectedReceipt.receiptDetails}" style="width: 300px"> 

                    <p:column headerText="Quantity">
                        <h:outputText value="#{receiptDetail.quantity}"/>
                    </p:column>

                    <p:column headerText="Vol Height">
                        <h:outputText value="#{receiptDetail.volHeight}"/>
                    </p:column>

                    <p:column headerText="Vol Lenght">
                        <h:outputText value="#{receiptDetail.volLenght}"/>
                    </p:column>

                    <p:column headerText="Vol Width">
                        <h:outputText value="#{receiptDetail.volWidth}"/>
                    </p:column>

                    <p:column headerText="Weight">
                        <h:outputText value="#{receiptDetail.weight}"/>
                    </p:column>
                    <p:column headerText="Type">
                        <h:outputText value="#{receiptDetail.type}"/>
                    </p:column>

                    <p:column style="width:4%">
                        <p:commandButton id="editDetailButton" update=":frmDialog" oncomplete="newReceiptDetailDialog.show();" icon="ui-icon-pencil" title="Edit">
                            <f:setPropertyActionListener value="#{receiptDetail}" target="#{receiptBackBean.selectedReceiptDetail}" />  
                        </p:commandButton>
                    </p:column>
                </p:dataTable>
                <p:separator/>  
                <p:commandButton value="Save" type="submit" update="frmDialog" actionListener="#{receiptBackBean.saveReceipt}" icon="ui-icon-check"/>  
                <p:commandButton value="Close" 
                                 type="submit" 
                                 onclick="carDialog2.hide();" 
                                 label="Close" 
                                 process="@this" 
                                 actionListener="#{receiptBackBean.reset}" 
                                 title="Close" 
                                 update="frmDialog" 
                                 icon="ui-icon-close"/>
            </h:form>    
        </p:dialog>
    </h:body>

</html>